You can easily extend the RapidSpellGUI class to customise the GUI design, preserving all the functionality of the original GUI. To do so the only contract is that your sub-class overrides buildGUI(), calls getContentPane().add(X) to add your design to the JFrame and uses these protected fields as GUI components;
JButton | addButton | Function button - adds word in the query pane to user dictionary if specified. |
JButton | cancelButton | Function button - cancels the search and disposes of this JFrame. |
JButton | changeButton | Function button - changes current misspelt word in document to
selected suggestion
or amended query pane word. |
JButton | changeAllButton | Function button - changes every occurrence of current misspelt word
in
document. |
JButton | ignoreAllButton | Function button - ignores all occurrences of current misspelt (bad) word. |
JButton | ignoreButton | Function button - ignores current bad word and continues checking document. |
JTextArea | queryWordPane | JTextArea where not in dictionary (bad words) are queried and replacements can be entered. |
JList | suggestionsList | JList where suggestions are loaded |
JCheckBox | suggestionFinderCheckBox | Check box - enables/disables the suggestion finder. |
JLabel | notInDictionaryLabel | JLabel marking the not in dictionary query pane. |
JLabel | suggestionsLabel | JLabel marking the suggestions JList, is changed to "Finding Suggestions..." periodically. |
boolean | findSuggestions | Whether this should look up suggestions for misspelt words or not. |
A very simple example would be the following code, which can be called instead of RapidSpellGUI but used in the same manner.
import com.keyoti.rapidSpell.desktop.RapidSpellGUI; import javax.swing.*; import java.awt.*; public class CustomGUI extends RapidSpellGUI { public CustomGUI() { super(); } // VERY SIMPLE, BUT UGLY LOOKING EXAMPLE public void buildGUI() { Box myBox = Box.createVerticalBox(); //define the protected fields as I want ignoreButton.setText("Ignore"); ignoreAllButton.setText("Ignore All"); changeButton.setText("Change"); changeAllButton.setText("Change All"); cancelButton.setText("Cancel"); //add all the protected fields I want to use and layout as I wish myBox.add(notInDictionaryLabel); myBox.add(queryWordPane); myBox.add(ignoreButton); myBox.add(ignoreAllButton); myBox.add(new JScrollPane(suggestionsList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED )); myBox.add(changeButton); myBox.add(changeAllButton); myBox.add(cancelButton); getContentPane().add(myBox); } }
Notice that the protected fields of RapidSpellGUI were used with out declaration and without adding any listeners to them.